package com.openvid.webrtc.openvid;

import android.util.Log;

import org.webrtc.AudioTrack;
import org.webrtc.IceCandidate;
import org.webrtc.MediaStream;
import org.webrtc.PeerConnection;
import org.webrtc.VideoTrack;

import java.util.ArrayList;
import java.util.List;

public abstract class Participant implements IParticipant{

    protected String connectionId;
    protected String participantName;
    protected List<IceCandidate> iceCandidateList = new ArrayList<>();

    protected PeerConnection peerConnection;

    public Participant(String participantName) {
        this.participantName = participantName;
    }

    @Override
    public String getConnectionId() {
        return this.connectionId;
    }

    @Override
    public void setConnectionId(String connectionId) {
        this.connectionId = connectionId;
    }

    @Override
    public String getParticipantName() {
        return this.participantName;
    }

    @Override
    public List<IceCandidate> getIceCandidateList() {
        return this.iceCandidateList;
    }

    @Override
    public PeerConnection getPeerConnection() {
        return peerConnection;
    }

    @Override
    public void setPeerConnection(PeerConnection peerConnection) {
        this.peerConnection = peerConnection;
    }

    @Override
    public void dispose() {
        if (this.peerConnection != null) {
            try {
                this.peerConnection.close();
            } catch (IllegalStateException e) {
                Log.e("Dispose PeerConnection", e.getMessage());
            }
        }
    }
}
